﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MTO.Library.Domain.Repositories;
using MTO.Library.Domain;
using MTO.Library.Data.EF;

namespace MTO.Library.Data
{
    public class ProductRepository : IProductRepository
    {
        Entities appContext;

        public ProductRepository(Entities appContext)
        {
            this.appContext = appContext;
        }

        public IEnumerable<Product> GetAllProducts()
        {
            return this.appContext.Products.ToList();
        }

        public virtual void SaveOrUpdate(Product product)
        {
            if (appContext.Products.Find(product.ProductId) == null)
            {
                appContext.Products.Add(product);
            }

            //appContext.SaveChanges();
        }
    }
}
